package com.itheima.test0906.test05;

import java.util.Random;
import java.util.Scanner;

public class RandomNumHandlerDemo {
    public static void main(String[] args) {
        useRandomNumHandler(new RandomNumHandler() {
            @Override
            public int getNumber() {
                Random random = new Random();
                int i = random.nextInt(15) + 1;
                return i;
            }
        });

        useRandomNumHandler(()->{
            Random random = new Random();
            int i = random.nextInt(15) + 1;
            return i;
        });
    }

    public static void useRandomNumHandler(RandomNumHandler randomNumHandler){
        int result = randomNumHandler.getNumber();
        System.out.println(result);
    }
}

interface RandomNumHandler{
    public abstract int getNumber();
}
